package liumengbaio.lolzhangyoubao.Activity.Adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.InFo.MoreWallpaperInfo;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/13.
 */
public class MoreWallpaperPicAdapter extends PagerAdapter {


    private Context context;
    private List<MoreWallpaperInfo.DataBean> dataBeen;
    private View view;

    public MoreWallpaperPicAdapter(Context context, List<MoreWallpaperInfo.DataBean> dataBeen) {

        this.context = context;
        this.dataBeen = dataBeen;
    }

    @Override
    public int getCount() {
        return dataBeen.size();
    }

    //判断是否由对象生成页面
    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    //返回一个对象，这个对象表明了PagerAdapter适配器选择哪个对象放在当前的ViewPager中
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        view = View.inflate(context, R.layout.item_more_wallpaper_two, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.iv);
        Picasso.with(context).load(dataBeen.get(position).getPic_url()).into(imageView);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        //super.destroyItem(container, position, object);
    }
}
